package cn.iocoder.yudao.module.pay.convert.wallet;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.recharge.PayWalletRechargeRespVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Mapper
public interface PayWalletRechargeConvert {

    PayWalletRechargeConvert INSTANCE = Mappers.getMapper(PayWalletRechargeConvert.class);

    @Mapping(target = "totalPrice", expression = "java( payPrice + bonusPrice)")
    PayWalletRechargeDO convert(Long walletId, Integer payPrice, Integer bonusPrice, Long packageId);

    AppPayWalletRechargeCreateRespVO convert(PayWalletRechargeDO bean);

    default PayWalletRechargeRespVO convert02(PayWalletRechargeDO bean){
        if ( bean == null ) {
            return null;
        }

        PayWalletRechargeRespVO respVO = new PayWalletRechargeRespVO();

        respVO.setId( bean.getId() );
        respVO.setPayPrice(bean.getPayPrice());
        respVO.setWalletId(bean.getWalletId());
        respVO.setPayStatus(bean.getPayStatus());
        respVO.setBonusPrice(bean.getBonusPrice());
        respVO.setPackageId(bean.getPackageId());
        respVO.setPayTime(bean.getPayTime());
        respVO.setTotalPrice(bean.getTotalPrice());

        return respVO;
    }

    default PageResult<PayWalletRechargeRespVO> convertPage(PageResult<PayWalletRechargeDO> pageResult) {

        List<PayWalletRechargeRespVO> list = new ArrayList<>();
        for(int i = 0; i<pageResult.getList().size(); i++){
            list.add(convert02(pageResult.getList().get(i)));
        }
        return new PageResult<>(list, pageResult.getTotal());
    }

}
